<?php
/**
 * 2016.8.10 遍历文件夹类
 * User: wuz
 * Date: 2016/8/11
 * Time: 10:15
 */
namespace Ycf\Lession\FormAndFile\TraversalFile;

/*递归遍历文件夹
 */
class TraversalFile
{
    public function file($dirname)
    {
        $dirHandle = opendir($dirname);
        while ($file = readdir($dirHandle)) {
            $dirFile = $dirname . "/" . $file;
            if ($file != '.' && $file != '..') {
                if (is_dir($dirFile)) {
                    echo "文件夹：" . $file . "<br>";
                    $this->file($dirFile);
                } else {
                    echo "文件：" . $file . "<br>";}
            }
        }
        closedir($dirHandle);
    }
}
